package models

import (
	"time"
)

type Agent struct {
	Id string `orm:"pk"`

	Name    string
	Deleted int32 `orm:"column(deleted)"`

	FolderId       *Folder `orm:"column(folder_id);rel(fk)"`
	AllowTestFlows int32
	Status         string
	LastStartTime  time.Time `orm:"column(last_start_time);type(datetime)"`
	HeartbeatTime  time.Time `orm:"column(heartbeat_time);type(datetime)"`

	ExecThreadCount int32
	AutoRefresh     int32

	CreateTime     time.Time `orm:"column(create_time);type(datetime)"`
	CreateBy       string    `orm:"column(create_by)"`
	LastUpdateBy   string    `orm:"column(last_update_by)"`
	LastUpdateTime time.Time `orm:"column(last_update_time);type(datetime)"`

	ShowResourcesInExploreView int32

	AgentDeployments []*AgentDeployment `orm:"reverse(many)"` // fk 的反向关系
}

type AgentDeployment struct {
	Id string `orm:"pk"`

	Name    string
	AgentId *Agent `orm:"column(agent_id);rel(fk)"`

	FlowId *Flow `orm:"column(flow_id);rel(fk)"`

	StartType       string `orm:"column(start_type)"`
	LogLevel        string `orm:"column(log_level)"`
	StartExpression string `orm:"column(start_expression)"`
	Status          string

	Message string

	CreateTime     time.Time `orm:"column(create_time);type(datetime)"`
	CreateBy       string    `orm:"column(create_by)"`
	LastUpdateBy   string    `orm:"column(last_update_by)"`
	LastUpdateTime time.Time `orm:"column(last_update_time);type(datetime)"`
}

type AgentFlowDeploymentParameter struct {
	FolderId          *Folder          `orm:"column(folder_id);rel(fk)"`
	AgentDeploymentId *AgentDeployment `orm:"column(agent_deployment_id);rel(fk)"`

	Name  string
	Value string `orm:"column(value);type(longtext)"`

	CreateTime     time.Time `orm:"column(create_time);type(datetime)"`
	CreateBy       string    `orm:"column(create_by)"`
	LastUpdateBy   string    `orm:"column(last_update_by)"`
	LastUpdateTime time.Time `orm:"column(last_update_time);type(datetime)"`
}
